/*
 * @lc app=leetcode.cn id=345 lang=javascript
 *
 * [345] 反转字符串中的元音字母
 */

// @lc code=start
/**
 * @param {string} s
 * @return {string}
 */
var reverseVowels = function(s) {
    
    s=s.split("")
    let l=0,r=s.length-1
    let set=new Set(['a','e','i','o','u',"A","E","I","O","U"])
    while (l<r) {
       if(set.has(s[l])&&set.has(s[r])){
           let temp=s[r]
           s[r]=s[l]
           s[l]=temp
           r--
           l++
       }else if(set.has(s[l])&&!set.has(s[r])){
           r--
       }else if(!set.has(s[l])&&set.has(s[r])){
           l++
       }else{
           r--;l++
       }
    }
    return s.join("")
};
// @lc code=end

